﻿@namespace MudBlazor.UnitTests.TestComponents

<MudDataGrid Items="@_items" MultiSelection @bind-SelectedItems="_selectedItems" Filterable Bordered>
    <Columns>
        @*<TemplateColumn Title="Select Template Column" Sortable="false" Resizable="false" ShowColumnOptions="false" HeaderStyle="width:0%"
                        Filterable="false">
            <HeaderTemplate>

                    <MudCheckBox T="bool" Size="Size.Small" Checked="@context.IsAllSelected" CheckedChanged="@context.Actions.SetSelectAll" />
                
            </HeaderTemplate>
            <CellTemplate>
                <MudCheckBox T="bool" Size="Size.Small" Checked="@context.IsSelected" CheckedChanged="@context.Actions.SetSelectedItem" />
            </CellTemplate>
            <FooterTemplate>
                    <MudCheckBox T="bool" Size="Size.Small" Checked="@context.IsAllSelected" CheckedChanged="@context.Actions.SetSelectAll" />
            </FooterTemplate>
        </TemplateColumn>*@
        <SelectColumn />
        <PropertyColumn Property="x => x.Name" />
    </Columns>
</MudDataGrid>

<div>
    @string.Join(",", _selectedItems.Select(x => x.Name))
</div>

@code {
    private List<Item> _items = new List<Item>();

    private HashSet<Item> _selectedItems = new();

    protected override void OnInitialized()
    {
        var letters = "ABBC";
        foreach (var c in letters)
        {
            _items.Add(new Item(c.ToString()));
        }
    }

    public class Item
    {
        public string Name { get; set; }

        public Item(string name)
        {
            Name = name;
        }
    }
}
